1. Field of the Invention
The present invention relates to a method and system for calculating CRC (Cyclic Redundancy Check).
2. Description of the Related Art
“Cyclic Redundancy Check”, abbreviated by CRC in the follows, due to its adequate easy implementation for encoding and decoding, and its stronger, powerful error detecting ability, it becomes the most common checking code on the current computer network. The usual application is archiving, disk controller, Ethernet and iSCSI, etc. The present computer network commonly utilizes CRC tech accompanied with re-sent mechanism to confirm the datum correctness.
In some network application, for example, iSCSI (Internet Small Computer System Interface) layer will add wanted sending data with its respective CRC codes to form one message (message, or called by Protocol Data Unit: PDU) and then assign it to the transmitting end of TCP/IP layer. The TCP/IP transmitting end will slice the iSCSI message into some segments and send them out according to the maximum segment size (MSS) committed with the TCP/IP receiving end. When TCP/IP receiving end receives segments, it firstly stores them in the Memory, and after all segments of iSCSI messages are collected completely, assigns the iSCSI messages to iSCSI layer of the receiving end for CRC. Afterward, the iSCSI of the receiving end must read the iSCSI messages from the Memory to conduct CRC computation. In the example, CRC computation can only be conducted after all segments of iSCSI messages are collected completely, hence a delay time resulted. Furthermore, to conduct CRC computation, the iSCSI receiver must read messages from the Memory and consequently add loads to the Memory bus and impact the system performance. The above is the first conventional CRC method.
In the second conventional CRC, CRC is calculated immediately as each segment is received in the receiving end, and computed intermediate results are accumulated in the receiving logic. As successor segments are received, the successor segments and the intermediate result are calculated continuously. By this way, after all segments are received, the intermediate result of the receiving logic is the final CRC result. The second conventional method can refer to US Pub. No. US2006/0114909, the second conventional method may avoid a longer delay and extra Memory accessing. Because the current network packet routing usually apply to uninsured sequential principle (like IP protocol), so its applicability can be greatly reduced. Additionally, for the aspect of each network connection management in the second conventional method, as the number of connections gets more, the design complexity will increase tremendously, it will eclipse the implementation.
In the third conventional CRC method, CRC is calculated immediately as each segment is received so as to obtain a partial CRC. The partial CRC can be adjusted to obtain its corresponding CRC of sub-message. After each CRC of sub-messages is computed, all the CRCs are merged to obtain the final CRC result. The third conventional method can refer to PCT (patent cooperated treatment) WO03/084078, US patent No. U.S. Pat. No. 6,904,558, US Pub. No. US2003/0167440 and US Pub. No. US2006/0009952. It targets mainly on modulo function characteristic for decomposing, and utilizes the finite field multiplication with table looking up to adjust CRC of sub-message.